<template>
  <c-dialog
    width="500px"
    :title="multLang('title_qr_a')"
    :visible="visible"
    @update:visible="$emit('update:visible', $event)"
    custom-class="c-dialog-qrcode"
    @open="open"
  >
    <c-row>
      <c-col :col="8" top>
        <c-row :col="12">
          <c-col>
            <c-row>
              <c-col :col="5" right>
                <span class="c-dialog-qrcode-label">
                  {{ multLang('title_asset_ae', ':') }}
                </span>
              </c-col>
              <c-col :col="7" left>
                <span class="c-dialog-qrcode-text">{{ info.asset_code }}</span>
              </c-col>
            </c-row>
          </c-col>
          <c-col>
            <c-row>
              <c-col :col="5" right>
                <span class="c-dialog-qrcode-label">
                  {{ multLang('title_asset_a', ':') }}
                </span>
              </c-col>
              <c-col :col="7" left>
                <span class="c-dialog-qrcode-text">{{ info.asset_name }}</span>
              </c-col>
            </c-row>
          </c-col>
          <c-col>
            <c-row>
              <c-col :col="5" right>
                <span class="c-dialog-qrcode-label">
                  {{ multLang('title_asset_g', ':') }}
                </span>
              </c-col>
              <c-col :col="7" left>
                <span class="c-dialog-qrcode-text">
                  {{ info.position_name }}
                </span>
              </c-col>
            </c-row>
          </c-col>
          <c-col>
            <c-row>
              <c-col :col="5" right>
                <span class="c-dialog-qrcode-label">
                  {{ multLang('title_date_a', ':') }}
                </span>
              </c-col>
              <c-col :col="7" left>
                <span class="c-dialog-qrcode-text">{{ info.enable_time }}</span>
              </c-col>
            </c-row>
          </c-col>
        </c-row>
      </c-col>
      <c-col :col="4">
        <div class="c-dialog-qrcode-img">
          <el-image :src="getQRCode()" fit="contain" :lazy="true">
            <div slot="placeholder" class="image-slot">
              {{ multLang('text_ae') }}
            </div>
          </el-image>
        </div>
        <div class="c-dialog-qrcode-down">
          <el-button type="text" @click="downQRcode">
            {{ multLang('btn_down_a') }}
          </el-button>
        </div>
      </c-col>
    </c-row>
  </c-dialog>
</template>
<script>
import { exportSelectQRCode } from '@/http/api/v1/eqpt'
import { getQRCode } from '@/http/api/v1/file'
export default {
  name: 'CDialogQrcode',
  components: {},
  props: {
    info: {
      type: Object,
      default() {
        return {}
      }
    },
    visible: { type: Boolean, default: false }
  },
  data() {
    return {}
  },
  computed: {},
  watch: {},
  beforeCreate() {},
  created() {},
  beforeMount() {},
  mounted() {},
  beforeUpdate() {},
  updated() {},
  activated() {},
  deactivated() {},
  beforeDestroy() {},
  destroyed() {},
  methods: {
    open() {},
    downQRcode() {
      exportSelectQRCode({
        ids: this.info.id
      })
    },
    getQRCode() {
      return getQRCode(this.info.id)
    }
  }
}
</script>
<style lang="scss">
.c-dialog-qrcode {
  height: 280px;
  &-label,
  &-text {
    display: inline-block;
    font-size: 14px;
    padding: 12px 0;
  }
  &-label {
    color: #666;
  }
  &-text {
    color: #333;
    padding: 10px;
  }
  &-img {
    margin-top: 12px;
    .el-image {
      @include wh(120px, 120px);
    }
  }
  &-down {
    .el-button {
      font-size: 14px;
      padding: 10px;
    }
  }
  &-img,
  &-down {
    text-align: center;
  }
}
</style>
